var xhr;
var selected = new Array();//已经选中的用户
var count = 0;
var editor;

function checkname(){
	var idPost = document.getElementById("idPost");
	var id = 0;
	var name = document.getElementById("postname").value;
	if(name =='' || name.length > 30){
		return;
	}
	if(idPost != null){//修改专题
		id = parseInt(idPost.value);
		var url = "json/forum-checkPostName.html?postName=" + name;
		xhr = null;
		xhr = connectXHR(url, checkresult);
	}else{//增加专题
		var url = "json/forum-checkPostName.html?postName=" + name ;
		xhr = null;
		xhr = connectXHR(url, checkresult);
	}
}
function checkresult(){
	if(xhr == null)return;
	if(xhr.readyState == 4 && xhr.status == 200) {
		var data = eval('(' + xhr.responseText + ')');
		
		if(data == 1){
			$( "#dialog" ).dialog( "open" );
		}else{
			editor.sync();
			document.getElementById("addpost").submit();
		}
	}
}
